{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "ecg_signals_age_raw creates pickle datasets in the form: ecg signals x age, containing ecg signals amplitud and corresponding patient age class"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import h5py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "normal_ecg_age = pd.read_pickle('normal_ecg_age.pickle')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ECG_ID</th>\n",
       "      <th>Age</th>\n",
       "      <th>Age_class</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A00002</td>\n",
       "      <td>32</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   ECG_ID  Age  Age_class\n",
       "0  A00002   32          2"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "normal_ecg_age.head(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Working only with ecg derivation I. Could be used for including other derivations son reduction based on average value of all derivations at same coordinate. Need to be considered waveforms"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "temp_signal = []\n",
    "signal_age_dataframe = pd.DataFrame(columns = ['id', *range(0,1000), 'Age_class'])\n",
    "for id, age in zip(normal_ecg_age['ECG_ID'], normal_ecg_age['Age_class']):\n",
    "    with h5py.File(f'E:/1-DENIS/Biomarkers/SPH dataset/records/{id}.h5', 'r') as f:\n",
    "        temp_signal = list(f['ecg'][0][0:1000])\n",
    "        temp_signal.insert(0, id)\n",
    "        temp_signal.append(age)\n",
    "    signal_age_dataframe.loc[len(signal_age_dataframe)] = temp_signal\n",
    "    temp_signal = []\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>...</th>\n",
       "      <th>991</th>\n",
       "      <th>992</th>\n",
       "      <th>993</th>\n",
       "      <th>994</th>\n",
       "      <th>995</th>\n",
       "      <th>996</th>\n",
       "      <th>997</th>\n",
       "      <th>998</th>\n",
       "      <th>999</th>\n",
       "      <th>Age_class</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A00002</td>\n",
       "      <td>-0.037598</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.044006</td>\n",
       "      <td>-0.045593</td>\n",
       "      <td>-0.046387</td>\n",
       "      <td>-0.044800</td>\n",
       "      <td>-0.043213</td>\n",
       "      <td>-0.041595</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.017593</td>\n",
       "      <td>-0.016006</td>\n",
       "      <td>-0.014397</td>\n",
       "      <td>-0.016006</td>\n",
       "      <td>-0.019196</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.033600</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>A00003</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.059204</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.010399</td>\n",
       "      <td>-0.006401</td>\n",
       "      <td>0.013603</td>\n",
       "      <td>-0.009598</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.033600</td>\n",
       "      <td>-0.059204</td>\n",
       "      <td>-0.070374</td>\n",
       "      <td>-0.067993</td>\n",
       "      <td>-0.070374</td>\n",
       "      <td>-0.022400</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.032013</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>A00006</td>\n",
       "      <td>-0.044006</td>\n",
       "      <td>-0.052002</td>\n",
       "      <td>-0.045593</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.037598</td>\n",
       "      <td>-0.028793</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.050415</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.025604</td>\n",
       "      <td>-0.024796</td>\n",
       "      <td>-0.013603</td>\n",
       "      <td>-0.015198</td>\n",
       "      <td>-0.027206</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.012001</td>\n",
       "      <td>-0.010399</td>\n",
       "      <td>-0.020798</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>A00008</td>\n",
       "      <td>-0.036011</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.045593</td>\n",
       "      <td>-0.047211</td>\n",
       "      <td>-0.046387</td>\n",
       "      <td>-0.044800</td>\n",
       "      <td>-0.041595</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.025604</td>\n",
       "      <td>-0.022400</td>\n",
       "      <td>-0.020004</td>\n",
       "      <td>-0.020798</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.024796</td>\n",
       "      <td>-0.026398</td>\n",
       "      <td>-0.027206</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>A00009</td>\n",
       "      <td>-0.093628</td>\n",
       "      <td>-0.090393</td>\n",
       "      <td>-0.089600</td>\n",
       "      <td>-0.089600</td>\n",
       "      <td>-0.088806</td>\n",
       "      <td>-0.088013</td>\n",
       "      <td>-0.088013</td>\n",
       "      <td>-0.089600</td>\n",
       "      <td>-0.091187</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.051208</td>\n",
       "      <td>-0.051208</td>\n",
       "      <td>-0.052795</td>\n",
       "      <td>-0.056000</td>\n",
       "      <td>-0.059204</td>\n",
       "      <td>-0.061615</td>\n",
       "      <td>-0.059998</td>\n",
       "      <td>-0.056793</td>\n",
       "      <td>-0.052795</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13900</th>\n",
       "      <td>A25755</td>\n",
       "      <td>-0.022400</td>\n",
       "      <td>-0.026398</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.025604</td>\n",
       "      <td>-0.024002</td>\n",
       "      <td>-0.026398</td>\n",
       "      <td>-0.031204</td>\n",
       "      <td>-0.036011</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>...</td>\n",
       "      <td>0.105591</td>\n",
       "      <td>0.099976</td>\n",
       "      <td>0.096008</td>\n",
       "      <td>0.092773</td>\n",
       "      <td>0.090393</td>\n",
       "      <td>0.088806</td>\n",
       "      <td>0.086426</td>\n",
       "      <td>0.081604</td>\n",
       "      <td>0.076782</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13901</th>\n",
       "      <td>A25756</td>\n",
       "      <td>0.025604</td>\n",
       "      <td>0.033600</td>\n",
       "      <td>0.040009</td>\n",
       "      <td>0.042389</td>\n",
       "      <td>0.039215</td>\n",
       "      <td>0.032806</td>\n",
       "      <td>0.027206</td>\n",
       "      <td>0.028000</td>\n",
       "      <td>0.033600</td>\n",
       "      <td>...</td>\n",
       "      <td>0.091187</td>\n",
       "      <td>0.083191</td>\n",
       "      <td>0.075989</td>\n",
       "      <td>0.066406</td>\n",
       "      <td>0.058411</td>\n",
       "      <td>0.057587</td>\n",
       "      <td>0.062408</td>\n",
       "      <td>0.062408</td>\n",
       "      <td>0.048798</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13902</th>\n",
       "      <td>A25757</td>\n",
       "      <td>-0.116821</td>\n",
       "      <td>-0.098389</td>\n",
       "      <td>-0.075195</td>\n",
       "      <td>-0.056000</td>\n",
       "      <td>-0.042389</td>\n",
       "      <td>-0.031204</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.057587</td>\n",
       "      <td>...</td>\n",
       "      <td>0.012001</td>\n",
       "      <td>0.011200</td>\n",
       "      <td>-0.001600</td>\n",
       "      <td>-0.017593</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.031204</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.020004</td>\n",
       "      <td>-0.009598</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13903</th>\n",
       "      <td>A25764</td>\n",
       "      <td>-0.153564</td>\n",
       "      <td>-0.248779</td>\n",
       "      <td>-0.336914</td>\n",
       "      <td>-0.422363</td>\n",
       "      <td>-0.489502</td>\n",
       "      <td>-0.522461</td>\n",
       "      <td>-0.520020</td>\n",
       "      <td>-0.491943</td>\n",
       "      <td>-0.451904</td>\n",
       "      <td>...</td>\n",
       "      <td>0.037598</td>\n",
       "      <td>0.045593</td>\n",
       "      <td>0.048004</td>\n",
       "      <td>0.046387</td>\n",
       "      <td>0.045593</td>\n",
       "      <td>0.046387</td>\n",
       "      <td>0.045593</td>\n",
       "      <td>0.040802</td>\n",
       "      <td>0.036804</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13904</th>\n",
       "      <td>A25765</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>-0.040009</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>-0.032013</td>\n",
       "      <td>-0.022400</td>\n",
       "      <td>...</td>\n",
       "      <td>0.096802</td>\n",
       "      <td>0.101624</td>\n",
       "      <td>0.107178</td>\n",
       "      <td>0.108826</td>\n",
       "      <td>0.103210</td>\n",
       "      <td>0.090393</td>\n",
       "      <td>0.072021</td>\n",
       "      <td>0.053589</td>\n",
       "      <td>0.036804</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>13905 rows × 1002 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           id         0         1         2         3         4         5  \\\n",
       "0      A00002 -0.037598 -0.038391 -0.040802 -0.044006 -0.045593 -0.046387   \n",
       "1      A00003 -0.040802 -0.040802 -0.036804 -0.059204 -0.048004 -0.010399   \n",
       "2      A00006 -0.044006 -0.052002 -0.045593 -0.039215 -0.037598 -0.028793   \n",
       "3      A00008 -0.036011 -0.040802 -0.045593 -0.047211 -0.046387 -0.044800   \n",
       "4      A00009 -0.093628 -0.090393 -0.089600 -0.089600 -0.088806 -0.088013   \n",
       "...       ...       ...       ...       ...       ...       ...       ...   \n",
       "13900  A25755 -0.022400 -0.026398 -0.028000 -0.025604 -0.024002 -0.026398   \n",
       "13901  A25756  0.025604  0.033600  0.040009  0.042389  0.039215  0.032806   \n",
       "13902  A25757 -0.116821 -0.098389 -0.075195 -0.056000 -0.042389 -0.031204   \n",
       "13903  A25764 -0.153564 -0.248779 -0.336914 -0.422363 -0.489502 -0.522461   \n",
       "13904  A25765 -0.036804 -0.036804 -0.038391 -0.040009 -0.040802 -0.040802   \n",
       "\n",
       "              6         7         8  ...       991       992       993  \\\n",
       "0     -0.044800 -0.043213 -0.041595  ... -0.017593 -0.016006 -0.014397   \n",
       "1     -0.006401  0.013603 -0.009598  ... -0.033600 -0.059204 -0.070374   \n",
       "2     -0.039215 -0.048004 -0.050415  ... -0.025604 -0.024796 -0.013603   \n",
       "3     -0.041595 -0.039215 -0.038391  ... -0.025604 -0.022400 -0.020004   \n",
       "4     -0.088013 -0.089600 -0.091187  ... -0.051208 -0.051208 -0.052795   \n",
       "...         ...       ...       ...  ...       ...       ...       ...   \n",
       "13900 -0.031204 -0.036011 -0.040802  ...  0.105591  0.099976  0.096008   \n",
       "13901  0.027206  0.028000  0.033600  ...  0.091187  0.083191  0.075989   \n",
       "13902 -0.028000 -0.039215 -0.057587  ...  0.012001  0.011200 -0.001600   \n",
       "13903 -0.520020 -0.491943 -0.451904  ...  0.037598  0.045593  0.048004   \n",
       "13904 -0.038391 -0.032013 -0.022400  ...  0.096802  0.101624  0.107178   \n",
       "\n",
       "            994       995       996       997       998       999  Age_class  \n",
       "0     -0.016006 -0.019196 -0.023193 -0.028000 -0.033600 -0.038391          2  \n",
       "1     -0.067993 -0.070374 -0.022400 -0.039215 -0.048004 -0.032013          5  \n",
       "2     -0.015198 -0.027206 -0.028000 -0.012001 -0.010399 -0.020798          3  \n",
       "3     -0.020798 -0.023193 -0.024796 -0.026398 -0.027206 -0.028000          2  \n",
       "4     -0.056000 -0.059204 -0.061615 -0.059998 -0.056793 -0.052795          3  \n",
       "...         ...       ...       ...       ...       ...       ...        ...  \n",
       "13900  0.092773  0.090393  0.088806  0.086426  0.081604  0.076782          3  \n",
       "13901  0.066406  0.058411  0.057587  0.062408  0.062408  0.048798          6  \n",
       "13902 -0.017593 -0.028000 -0.031204 -0.028000 -0.020004 -0.009598          4  \n",
       "13903  0.046387  0.045593  0.046387  0.045593  0.040802  0.036804          1  \n",
       "13904  0.108826  0.103210  0.090393  0.072021  0.053589  0.036804          4  \n",
       "\n",
       "[13905 rows x 1002 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "signal_age_dataframe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "signal_age_dataframe.to_pickle('signal_age_dataframe.pickle')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "signal_age_dataframe = pd.read_pickle('signal_age_dataframe.pickle')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>...</th>\n",
       "      <th>991</th>\n",
       "      <th>992</th>\n",
       "      <th>993</th>\n",
       "      <th>994</th>\n",
       "      <th>995</th>\n",
       "      <th>996</th>\n",
       "      <th>997</th>\n",
       "      <th>998</th>\n",
       "      <th>999</th>\n",
       "      <th>Age_class</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A00002</td>\n",
       "      <td>-0.037598</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.044006</td>\n",
       "      <td>-0.045593</td>\n",
       "      <td>-0.046387</td>\n",
       "      <td>-0.044800</td>\n",
       "      <td>-0.043213</td>\n",
       "      <td>-0.041595</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.017593</td>\n",
       "      <td>-0.016006</td>\n",
       "      <td>-0.014397</td>\n",
       "      <td>-0.016006</td>\n",
       "      <td>-0.019196</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.033600</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>A00003</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.059204</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.010399</td>\n",
       "      <td>-0.006401</td>\n",
       "      <td>0.013603</td>\n",
       "      <td>-0.009598</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.033600</td>\n",
       "      <td>-0.059204</td>\n",
       "      <td>-0.070374</td>\n",
       "      <td>-0.067993</td>\n",
       "      <td>-0.070374</td>\n",
       "      <td>-0.022400</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.032013</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>A00006</td>\n",
       "      <td>-0.044006</td>\n",
       "      <td>-0.052002</td>\n",
       "      <td>-0.045593</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.037598</td>\n",
       "      <td>-0.028793</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.050415</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.025604</td>\n",
       "      <td>-0.024796</td>\n",
       "      <td>-0.013603</td>\n",
       "      <td>-0.015198</td>\n",
       "      <td>-0.027206</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.012001</td>\n",
       "      <td>-0.010399</td>\n",
       "      <td>-0.020798</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>A00008</td>\n",
       "      <td>-0.036011</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.045593</td>\n",
       "      <td>-0.047211</td>\n",
       "      <td>-0.046387</td>\n",
       "      <td>-0.044800</td>\n",
       "      <td>-0.041595</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.025604</td>\n",
       "      <td>-0.022400</td>\n",
       "      <td>-0.020004</td>\n",
       "      <td>-0.020798</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.024796</td>\n",
       "      <td>-0.026398</td>\n",
       "      <td>-0.027206</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>A00009</td>\n",
       "      <td>-0.093628</td>\n",
       "      <td>-0.090393</td>\n",
       "      <td>-0.089600</td>\n",
       "      <td>-0.089600</td>\n",
       "      <td>-0.088806</td>\n",
       "      <td>-0.088013</td>\n",
       "      <td>-0.088013</td>\n",
       "      <td>-0.089600</td>\n",
       "      <td>-0.091187</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.051208</td>\n",
       "      <td>-0.051208</td>\n",
       "      <td>-0.052795</td>\n",
       "      <td>-0.056000</td>\n",
       "      <td>-0.059204</td>\n",
       "      <td>-0.061615</td>\n",
       "      <td>-0.059998</td>\n",
       "      <td>-0.056793</td>\n",
       "      <td>-0.052795</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 1002 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       id         0         1         2         3         4         5  \\\n",
       "0  A00002 -0.037598 -0.038391 -0.040802 -0.044006 -0.045593 -0.046387   \n",
       "1  A00003 -0.040802 -0.040802 -0.036804 -0.059204 -0.048004 -0.010399   \n",
       "2  A00006 -0.044006 -0.052002 -0.045593 -0.039215 -0.037598 -0.028793   \n",
       "3  A00008 -0.036011 -0.040802 -0.045593 -0.047211 -0.046387 -0.044800   \n",
       "4  A00009 -0.093628 -0.090393 -0.089600 -0.089600 -0.088806 -0.088013   \n",
       "\n",
       "          6         7         8  ...       991       992       993       994  \\\n",
       "0 -0.044800 -0.043213 -0.041595  ... -0.017593 -0.016006 -0.014397 -0.016006   \n",
       "1 -0.006401  0.013603 -0.009598  ... -0.033600 -0.059204 -0.070374 -0.067993   \n",
       "2 -0.039215 -0.048004 -0.050415  ... -0.025604 -0.024796 -0.013603 -0.015198   \n",
       "3 -0.041595 -0.039215 -0.038391  ... -0.025604 -0.022400 -0.020004 -0.020798   \n",
       "4 -0.088013 -0.089600 -0.091187  ... -0.051208 -0.051208 -0.052795 -0.056000   \n",
       "\n",
       "        995       996       997       998       999  Age_class  \n",
       "0 -0.019196 -0.023193 -0.028000 -0.033600 -0.038391          2  \n",
       "1 -0.070374 -0.022400 -0.039215 -0.048004 -0.032013          5  \n",
       "2 -0.027206 -0.028000 -0.012001 -0.010399 -0.020798          3  \n",
       "3 -0.023193 -0.024796 -0.026398 -0.027206 -0.028000          2  \n",
       "4 -0.059204 -0.061615 -0.059998 -0.056793 -0.052795          3  \n",
       "\n",
       "[5 rows x 1002 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "signal_age_dataframe.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>989</th>\n",
       "      <th>990</th>\n",
       "      <th>991</th>\n",
       "      <th>992</th>\n",
       "      <th>993</th>\n",
       "      <th>994</th>\n",
       "      <th>995</th>\n",
       "      <th>996</th>\n",
       "      <th>997</th>\n",
       "      <th>998</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.037598</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.044006</td>\n",
       "      <td>-0.045593</td>\n",
       "      <td>-0.046387</td>\n",
       "      <td>-0.044800</td>\n",
       "      <td>-0.043213</td>\n",
       "      <td>-0.041595</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.018402</td>\n",
       "      <td>-0.018402</td>\n",
       "      <td>-0.017593</td>\n",
       "      <td>-0.016006</td>\n",
       "      <td>-0.014397</td>\n",
       "      <td>-0.016006</td>\n",
       "      <td>-0.019196</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.033600</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.059204</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.010399</td>\n",
       "      <td>-0.006401</td>\n",
       "      <td>0.013603</td>\n",
       "      <td>-0.009598</td>\n",
       "      <td>-0.025604</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.033600</td>\n",
       "      <td>-0.029602</td>\n",
       "      <td>-0.033600</td>\n",
       "      <td>-0.059204</td>\n",
       "      <td>-0.070374</td>\n",
       "      <td>-0.067993</td>\n",
       "      <td>-0.070374</td>\n",
       "      <td>-0.022400</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.048004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-0.044006</td>\n",
       "      <td>-0.052002</td>\n",
       "      <td>-0.045593</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.037598</td>\n",
       "      <td>-0.028793</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.050415</td>\n",
       "      <td>-0.052002</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.016800</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.025604</td>\n",
       "      <td>-0.024796</td>\n",
       "      <td>-0.013603</td>\n",
       "      <td>-0.015198</td>\n",
       "      <td>-0.027206</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.012001</td>\n",
       "      <td>-0.010399</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.036011</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.045593</td>\n",
       "      <td>-0.047211</td>\n",
       "      <td>-0.046387</td>\n",
       "      <td>-0.044800</td>\n",
       "      <td>-0.041595</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.026398</td>\n",
       "      <td>-0.026398</td>\n",
       "      <td>-0.025604</td>\n",
       "      <td>-0.022400</td>\n",
       "      <td>-0.020004</td>\n",
       "      <td>-0.020798</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.024796</td>\n",
       "      <td>-0.026398</td>\n",
       "      <td>-0.027206</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-0.093628</td>\n",
       "      <td>-0.090393</td>\n",
       "      <td>-0.089600</td>\n",
       "      <td>-0.089600</td>\n",
       "      <td>-0.088806</td>\n",
       "      <td>-0.088013</td>\n",
       "      <td>-0.088013</td>\n",
       "      <td>-0.089600</td>\n",
       "      <td>-0.091187</td>\n",
       "      <td>-0.091980</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.053589</td>\n",
       "      <td>-0.052795</td>\n",
       "      <td>-0.051208</td>\n",
       "      <td>-0.051208</td>\n",
       "      <td>-0.052795</td>\n",
       "      <td>-0.056000</td>\n",
       "      <td>-0.059204</td>\n",
       "      <td>-0.061615</td>\n",
       "      <td>-0.059998</td>\n",
       "      <td>-0.056793</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13900</th>\n",
       "      <td>-0.022400</td>\n",
       "      <td>-0.026398</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.025604</td>\n",
       "      <td>-0.024002</td>\n",
       "      <td>-0.026398</td>\n",
       "      <td>-0.031204</td>\n",
       "      <td>-0.036011</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.044800</td>\n",
       "      <td>...</td>\n",
       "      <td>0.112000</td>\n",
       "      <td>0.110413</td>\n",
       "      <td>0.105591</td>\n",
       "      <td>0.099976</td>\n",
       "      <td>0.096008</td>\n",
       "      <td>0.092773</td>\n",
       "      <td>0.090393</td>\n",
       "      <td>0.088806</td>\n",
       "      <td>0.086426</td>\n",
       "      <td>0.081604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13901</th>\n",
       "      <td>0.025604</td>\n",
       "      <td>0.033600</td>\n",
       "      <td>0.040009</td>\n",
       "      <td>0.042389</td>\n",
       "      <td>0.039215</td>\n",
       "      <td>0.032806</td>\n",
       "      <td>0.027206</td>\n",
       "      <td>0.028000</td>\n",
       "      <td>0.033600</td>\n",
       "      <td>0.032013</td>\n",
       "      <td>...</td>\n",
       "      <td>0.101624</td>\n",
       "      <td>0.097595</td>\n",
       "      <td>0.091187</td>\n",
       "      <td>0.083191</td>\n",
       "      <td>0.075989</td>\n",
       "      <td>0.066406</td>\n",
       "      <td>0.058411</td>\n",
       "      <td>0.057587</td>\n",
       "      <td>0.062408</td>\n",
       "      <td>0.062408</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13902</th>\n",
       "      <td>-0.116821</td>\n",
       "      <td>-0.098389</td>\n",
       "      <td>-0.075195</td>\n",
       "      <td>-0.056000</td>\n",
       "      <td>-0.042389</td>\n",
       "      <td>-0.031204</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.057587</td>\n",
       "      <td>-0.072815</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.009598</td>\n",
       "      <td>0.001600</td>\n",
       "      <td>0.012001</td>\n",
       "      <td>0.011200</td>\n",
       "      <td>-0.001600</td>\n",
       "      <td>-0.017593</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.031204</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.020004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13903</th>\n",
       "      <td>-0.153564</td>\n",
       "      <td>-0.248779</td>\n",
       "      <td>-0.336914</td>\n",
       "      <td>-0.422363</td>\n",
       "      <td>-0.489502</td>\n",
       "      <td>-0.522461</td>\n",
       "      <td>-0.520020</td>\n",
       "      <td>-0.491943</td>\n",
       "      <td>-0.451904</td>\n",
       "      <td>-0.409668</td>\n",
       "      <td>...</td>\n",
       "      <td>0.009598</td>\n",
       "      <td>0.023193</td>\n",
       "      <td>0.037598</td>\n",
       "      <td>0.045593</td>\n",
       "      <td>0.048004</td>\n",
       "      <td>0.046387</td>\n",
       "      <td>0.045593</td>\n",
       "      <td>0.046387</td>\n",
       "      <td>0.045593</td>\n",
       "      <td>0.040802</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13904</th>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>-0.040009</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>-0.032013</td>\n",
       "      <td>-0.022400</td>\n",
       "      <td>-0.012802</td>\n",
       "      <td>...</td>\n",
       "      <td>0.097595</td>\n",
       "      <td>0.096802</td>\n",
       "      <td>0.096802</td>\n",
       "      <td>0.101624</td>\n",
       "      <td>0.107178</td>\n",
       "      <td>0.108826</td>\n",
       "      <td>0.103210</td>\n",
       "      <td>0.090393</td>\n",
       "      <td>0.072021</td>\n",
       "      <td>0.053589</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>13905 rows × 999 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            0         1         2         3         4         5         6    \\\n",
       "0     -0.037598 -0.038391 -0.040802 -0.044006 -0.045593 -0.046387 -0.044800   \n",
       "1     -0.040802 -0.040802 -0.036804 -0.059204 -0.048004 -0.010399 -0.006401   \n",
       "2     -0.044006 -0.052002 -0.045593 -0.039215 -0.037598 -0.028793 -0.039215   \n",
       "3     -0.036011 -0.040802 -0.045593 -0.047211 -0.046387 -0.044800 -0.041595   \n",
       "4     -0.093628 -0.090393 -0.089600 -0.089600 -0.088806 -0.088013 -0.088013   \n",
       "...         ...       ...       ...       ...       ...       ...       ...   \n",
       "13900 -0.022400 -0.026398 -0.028000 -0.025604 -0.024002 -0.026398 -0.031204   \n",
       "13901  0.025604  0.033600  0.040009  0.042389  0.039215  0.032806  0.027206   \n",
       "13902 -0.116821 -0.098389 -0.075195 -0.056000 -0.042389 -0.031204 -0.028000   \n",
       "13903 -0.153564 -0.248779 -0.336914 -0.422363 -0.489502 -0.522461 -0.520020   \n",
       "13904 -0.036804 -0.036804 -0.038391 -0.040009 -0.040802 -0.040802 -0.038391   \n",
       "\n",
       "            7         8         9    ...       989       990       991  \\\n",
       "0     -0.043213 -0.041595 -0.040802  ... -0.018402 -0.018402 -0.017593   \n",
       "1      0.013603 -0.009598 -0.025604  ... -0.033600 -0.029602 -0.033600   \n",
       "2     -0.048004 -0.050415 -0.052002  ... -0.016800 -0.023193 -0.025604   \n",
       "3     -0.039215 -0.038391 -0.039215  ... -0.026398 -0.026398 -0.025604   \n",
       "4     -0.089600 -0.091187 -0.091980  ... -0.053589 -0.052795 -0.051208   \n",
       "...         ...       ...       ...  ...       ...       ...       ...   \n",
       "13900 -0.036011 -0.040802 -0.044800  ...  0.112000  0.110413  0.105591   \n",
       "13901  0.028000  0.033600  0.032013  ...  0.101624  0.097595  0.091187   \n",
       "13902 -0.039215 -0.057587 -0.072815  ... -0.009598  0.001600  0.012001   \n",
       "13903 -0.491943 -0.451904 -0.409668  ...  0.009598  0.023193  0.037598   \n",
       "13904 -0.032013 -0.022400 -0.012802  ...  0.097595  0.096802  0.096802   \n",
       "\n",
       "            992       993       994       995       996       997       998  \n",
       "0     -0.016006 -0.014397 -0.016006 -0.019196 -0.023193 -0.028000 -0.033600  \n",
       "1     -0.059204 -0.070374 -0.067993 -0.070374 -0.022400 -0.039215 -0.048004  \n",
       "2     -0.024796 -0.013603 -0.015198 -0.027206 -0.028000 -0.012001 -0.010399  \n",
       "3     -0.022400 -0.020004 -0.020798 -0.023193 -0.024796 -0.026398 -0.027206  \n",
       "4     -0.051208 -0.052795 -0.056000 -0.059204 -0.061615 -0.059998 -0.056793  \n",
       "...         ...       ...       ...       ...       ...       ...       ...  \n",
       "13900  0.099976  0.096008  0.092773  0.090393  0.088806  0.086426  0.081604  \n",
       "13901  0.083191  0.075989  0.066406  0.058411  0.057587  0.062408  0.062408  \n",
       "13902  0.011200 -0.001600 -0.017593 -0.028000 -0.031204 -0.028000 -0.020004  \n",
       "13903  0.045593  0.048004  0.046387  0.045593  0.046387  0.045593  0.040802  \n",
       "13904  0.101624  0.107178  0.108826  0.103210  0.090393  0.072021  0.053589  \n",
       "\n",
       "[13905 rows x 999 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "signal_age_dataframe.iloc[:,1:1000]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "X_train, X_test, y_train, y_test = train_test_split(signal_age_dataframe.iloc[:,1:1000], signal_age_dataframe['Age_class'], random_state=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>990</th>\n",
       "      <th>991</th>\n",
       "      <th>992</th>\n",
       "      <th>993</th>\n",
       "      <th>994</th>\n",
       "      <th>995</th>\n",
       "      <th>996</th>\n",
       "      <th>997</th>\n",
       "      <th>998</th>\n",
       "      <th>Age_class</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5657</th>\n",
       "      <td>0.028000</td>\n",
       "      <td>0.027206</td>\n",
       "      <td>0.026398</td>\n",
       "      <td>0.026398</td>\n",
       "      <td>0.028793</td>\n",
       "      <td>0.032806</td>\n",
       "      <td>0.037598</td>\n",
       "      <td>0.043213</td>\n",
       "      <td>0.047211</td>\n",
       "      <td>0.050415</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.028793</td>\n",
       "      <td>-0.029602</td>\n",
       "      <td>-0.029602</td>\n",
       "      <td>-0.030396</td>\n",
       "      <td>-0.030396</td>\n",
       "      <td>-0.028793</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>-0.029602</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4951</th>\n",
       "      <td>-0.065613</td>\n",
       "      <td>-0.063171</td>\n",
       "      <td>-0.059998</td>\n",
       "      <td>-0.059204</td>\n",
       "      <td>-0.059204</td>\n",
       "      <td>-0.059204</td>\n",
       "      <td>-0.059998</td>\n",
       "      <td>-0.060791</td>\n",
       "      <td>-0.061615</td>\n",
       "      <td>-0.063171</td>\n",
       "      <td>...</td>\n",
       "      <td>0.007198</td>\n",
       "      <td>0.008003</td>\n",
       "      <td>0.008797</td>\n",
       "      <td>0.008797</td>\n",
       "      <td>0.009598</td>\n",
       "      <td>0.008797</td>\n",
       "      <td>0.005600</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-0.008797</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11333</th>\n",
       "      <td>-0.006401</td>\n",
       "      <td>-0.007198</td>\n",
       "      <td>-0.008003</td>\n",
       "      <td>-0.008797</td>\n",
       "      <td>-0.010399</td>\n",
       "      <td>-0.011200</td>\n",
       "      <td>-0.011200</td>\n",
       "      <td>-0.011200</td>\n",
       "      <td>-0.011200</td>\n",
       "      <td>-0.012001</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.036011</td>\n",
       "      <td>-0.035187</td>\n",
       "      <td>-0.032806</td>\n",
       "      <td>-0.027206</td>\n",
       "      <td>-0.016800</td>\n",
       "      <td>-0.000800</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5120</th>\n",
       "      <td>-0.018402</td>\n",
       "      <td>-0.024002</td>\n",
       "      <td>-0.025604</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.019196</td>\n",
       "      <td>-0.014397</td>\n",
       "      <td>-0.011200</td>\n",
       "      <td>-0.010399</td>\n",
       "      <td>-0.010399</td>\n",
       "      <td>-0.010399</td>\n",
       "      <td>...</td>\n",
       "      <td>0.024796</td>\n",
       "      <td>0.022400</td>\n",
       "      <td>0.018402</td>\n",
       "      <td>0.016800</td>\n",
       "      <td>0.018402</td>\n",
       "      <td>0.024002</td>\n",
       "      <td>0.032013</td>\n",
       "      <td>0.041595</td>\n",
       "      <td>0.052002</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8174</th>\n",
       "      <td>-0.067993</td>\n",
       "      <td>-0.060791</td>\n",
       "      <td>-0.060791</td>\n",
       "      <td>-0.064026</td>\n",
       "      <td>-0.071228</td>\n",
       "      <td>-0.078430</td>\n",
       "      <td>-0.080811</td>\n",
       "      <td>-0.076782</td>\n",
       "      <td>-0.069580</td>\n",
       "      <td>-0.066406</td>\n",
       "      <td>...</td>\n",
       "      <td>0.013603</td>\n",
       "      <td>0.016800</td>\n",
       "      <td>0.019196</td>\n",
       "      <td>0.016800</td>\n",
       "      <td>0.008797</td>\n",
       "      <td>0.000800</td>\n",
       "      <td>-0.001600</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.002399</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13123</th>\n",
       "      <td>-0.024796</td>\n",
       "      <td>-0.029602</td>\n",
       "      <td>-0.032806</td>\n",
       "      <td>-0.031204</td>\n",
       "      <td>-0.027206</td>\n",
       "      <td>-0.024002</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.021606</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.028000</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.043213</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.040802</td>\n",
       "      <td>-0.040009</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3264</th>\n",
       "      <td>-0.040009</td>\n",
       "      <td>-0.039215</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.037598</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.035187</td>\n",
       "      <td>-0.032806</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.047211</td>\n",
       "      <td>-0.046387</td>\n",
       "      <td>-0.047211</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.048004</td>\n",
       "      <td>-0.047211</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9845</th>\n",
       "      <td>-0.064026</td>\n",
       "      <td>-0.058411</td>\n",
       "      <td>-0.053589</td>\n",
       "      <td>-0.052002</td>\n",
       "      <td>-0.057587</td>\n",
       "      <td>-0.067200</td>\n",
       "      <td>-0.075989</td>\n",
       "      <td>-0.076782</td>\n",
       "      <td>-0.069580</td>\n",
       "      <td>-0.058411</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.038391</td>\n",
       "      <td>-0.031204</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.028793</td>\n",
       "      <td>-0.037598</td>\n",
       "      <td>-0.043213</td>\n",
       "      <td>-0.044800</td>\n",
       "      <td>-0.042389</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10799</th>\n",
       "      <td>-0.024002</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.021606</td>\n",
       "      <td>-0.020004</td>\n",
       "      <td>-0.018402</td>\n",
       "      <td>-0.017593</td>\n",
       "      <td>-0.018402</td>\n",
       "      <td>-0.020004</td>\n",
       "      <td>-0.021606</td>\n",
       "      <td>-0.023193</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.036804</td>\n",
       "      <td>-0.036011</td>\n",
       "      <td>-0.034393</td>\n",
       "      <td>-0.032806</td>\n",
       "      <td>-0.031204</td>\n",
       "      <td>-0.031204</td>\n",
       "      <td>-0.030396</td>\n",
       "      <td>-0.031204</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2732</th>\n",
       "      <td>-0.023193</td>\n",
       "      <td>-0.021606</td>\n",
       "      <td>-0.021606</td>\n",
       "      <td>-0.021606</td>\n",
       "      <td>-0.020798</td>\n",
       "      <td>-0.020004</td>\n",
       "      <td>-0.019196</td>\n",
       "      <td>-0.018402</td>\n",
       "      <td>-0.017593</td>\n",
       "      <td>-0.015198</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.064819</td>\n",
       "      <td>-0.069580</td>\n",
       "      <td>-0.073608</td>\n",
       "      <td>-0.075195</td>\n",
       "      <td>-0.076782</td>\n",
       "      <td>-0.076782</td>\n",
       "      <td>-0.076782</td>\n",
       "      <td>-0.075989</td>\n",
       "      <td>-0.075989</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10428 rows × 1000 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              0         1         2         3         4         5         6  \\\n",
       "5657   0.028000  0.027206  0.026398  0.026398  0.028793  0.032806  0.037598   \n",
       "4951  -0.065613 -0.063171 -0.059998 -0.059204 -0.059204 -0.059204 -0.059998   \n",
       "11333 -0.006401 -0.007198 -0.008003 -0.008797 -0.010399 -0.011200 -0.011200   \n",
       "5120  -0.018402 -0.024002 -0.025604 -0.023193 -0.019196 -0.014397 -0.011200   \n",
       "8174  -0.067993 -0.060791 -0.060791 -0.064026 -0.071228 -0.078430 -0.080811   \n",
       "...         ...       ...       ...       ...       ...       ...       ...   \n",
       "13123 -0.024796 -0.029602 -0.032806 -0.031204 -0.027206 -0.024002 -0.023193   \n",
       "3264  -0.040009 -0.039215 -0.038391 -0.036804 -0.036804 -0.036804 -0.037598   \n",
       "9845  -0.064026 -0.058411 -0.053589 -0.052002 -0.057587 -0.067200 -0.075989   \n",
       "10799 -0.024002 -0.023193 -0.021606 -0.020004 -0.018402 -0.017593 -0.018402   \n",
       "2732  -0.023193 -0.021606 -0.021606 -0.021606 -0.020798 -0.020004 -0.019196   \n",
       "\n",
       "              7         8         9  ...       990       991       992  \\\n",
       "5657   0.043213  0.047211  0.050415  ... -0.028000 -0.028793 -0.029602   \n",
       "4951  -0.060791 -0.061615 -0.063171  ...  0.007198  0.008003  0.008797   \n",
       "11333 -0.011200 -0.011200 -0.012001  ... -0.036804 -0.036804 -0.036804   \n",
       "5120  -0.010399 -0.010399 -0.010399  ...  0.024796  0.022400  0.018402   \n",
       "8174  -0.076782 -0.069580 -0.066406  ...  0.013603  0.016800  0.019196   \n",
       "...         ...       ...       ...  ...       ...       ...       ...   \n",
       "13123 -0.021606 -0.023193 -0.028000  ... -0.043213 -0.040802 -0.040802   \n",
       "3264  -0.036804 -0.035187 -0.032806  ... -0.047211 -0.046387 -0.047211   \n",
       "9845  -0.076782 -0.069580 -0.058411  ... -0.038391 -0.031204 -0.023193   \n",
       "10799 -0.020004 -0.021606 -0.023193  ... -0.036804 -0.036804 -0.036011   \n",
       "2732  -0.018402 -0.017593 -0.015198  ... -0.064819 -0.069580 -0.073608   \n",
       "\n",
       "            993       994       995       996       997       998  Age_class  \n",
       "5657  -0.029602 -0.030396 -0.030396 -0.028793 -0.028000 -0.029602          2  \n",
       "4951   0.008797  0.009598  0.008797  0.005600  0.000000 -0.008797          2  \n",
       "11333 -0.036011 -0.035187 -0.032806 -0.027206 -0.016800 -0.000800          3  \n",
       "5120   0.016800  0.018402  0.024002  0.032013  0.041595  0.052002          4  \n",
       "8174   0.016800  0.008797  0.000800 -0.001600  0.000000  0.002399          5  \n",
       "...         ...       ...       ...       ...       ...       ...        ...  \n",
       "13123 -0.040802 -0.040802 -0.040009 -0.038391 -0.036804 -0.039215          4  \n",
       "3264  -0.048004 -0.048004 -0.048004 -0.048004 -0.048004 -0.047211          3  \n",
       "9845  -0.023193 -0.028793 -0.037598 -0.043213 -0.044800 -0.042389          4  \n",
       "10799 -0.034393 -0.032806 -0.031204 -0.031204 -0.030396 -0.031204          6  \n",
       "2732  -0.075195 -0.076782 -0.076782 -0.076782 -0.075989 -0.075989          2  \n",
       "\n",
       "[10428 rows x 1000 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([X_train, y_train], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(10428, 999) (3477, 999)\n",
      "(10428,) (3477,)\n"
     ]
    }
   ],
   "source": [
    "print(X_train.shape, X_test.shape)\n",
    "print(y_train.shape, y_test.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "knn = KNeighborsClassifier(n_neighbors=5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>#sk-container-id-3 {color: black;background-color: white;}#sk-container-id-3 pre{padding: 0;}#sk-container-id-3 div.sk-toggleable {background-color: white;}#sk-container-id-3 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-3 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-3 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-3 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-3 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-3 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-3 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-3 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-3 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-3 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-3 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-3 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-3 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-3 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-3 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-3 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-3 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-3 div.sk-item {position: relative;z-index: 1;}#sk-container-id-3 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-3 div.sk-item::before, #sk-container-id-3 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-3 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-3 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-3 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-3 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-3 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-3 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-3 div.sk-label-container {text-align: center;}#sk-container-id-3 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-3 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-3\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>KNeighborsClassifier()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-3\" type=\"checkbox\" checked><label for=\"sk-estimator-id-3\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">KNeighborsClassifier</label><div class=\"sk-toggleable__content\"><pre>KNeighborsClassifier()</pre></div></div></div></div></div>"
      ],
      "text/plain": [
       "KNeighborsClassifier()"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "knn.fit(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test set score: 0.24\n"
     ]
    }
   ],
   "source": [
    "print(\"Test set score: {:.2f}\".format(knn.score(X_test, y_test)))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.8.5 ('ecg_biomarkers': venv)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "d39f5264c2f26cb0964d5a98dbbf3a9d2bc7301339817434e4f0ffa82f5f047f"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
